FROM idoall/ubuntu:16.04
MAINTAINER lion <lion.net@163.com>

ARG DEBIAN_FRONTEND=noninteractive

ENV FISHEYE_VERSION 4.6.1

# -----------------------------------------------------------------------------
# 安装 openjdk-8\
# -----------------------------------------------------------------------------
RUN apt-fast update -y \
    && apt-fast install -y subversion git unzip zip openjdk-8-jdk

# -----------------------------------------------------------------------------
# 下载 fisheye
# -----------------------------------------------------------------------------
RUN mkdir -p /home/work/_src \
    && axel -n 10 -o /home/work/_src/fisheye.tar.gz https://product-downloads.atlassian.com/software/fisheye/downloads/fisheye-$FISHEYE_VERSION.zip

# -----------------------------------------------------------------------------
# 安装 fisheye
# -----------------------------------------------------------------------------
RUN cd /home/work/_src \
    && unzip fisheye.tar.gz \
    && mkdir -p /home/work/_app/_jira_fisheye \
    && mv /home/work/_src/fecru-$FISHEYE_VERSION/* /home/work/_app/_jira_fisheye/ \
    && mkdir -p /home/work/_data/_jira_fisheye \
    && echo "FISHEYE_INST=/home/work/_data/_jira_fisheye" >> /etc/environment \
    && cp /home/work/_app/_jira_fisheye/config.xml /home/work/_data/_jira_fisheye/

# -----------------------------------------------------------------------------
# 安装 mysql 驱动 
# -----------------------------------------------------------------------------
RUN curl -Ls https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.47.tar.gz | tar -xz --directory /home/work/_src/ --strip-components=1 --no-same-owner \
    && cp -r /home/work/_src/mysql-connector-java-5.1.47-bin.jar /home/work/_app/_jira_fisheye/lib/


COPY files/ /


# -----------------------------------------------------------------------------
# 清除
# -----------------------------------------------------------------------------
RUN chmod 755 /hooks \
    && chown -R work:work /home/work/* \
    && apt-get -y clean \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /var/cache/apt/archives/apt-fast/* \
    && rm -rf /home/work/_src/*

# -----------------------------------------------------------------------------
# 设置环境变量
# -----------------------------------------------------------------------------
ENV FISHEYE_INST /home/work/_data/_jira_fisheye

# -----------------------------------------------------------------------------
# 映射端口
# -----------------------------------------------------------------------------
EXPOSE 8060

